from microbit import *
import music
import random

while True:
    a1 = accelerometer.get_y()
    sleep(50)
    a2 = accelerometer.get_y()
    if abs(a1 - a2) > 2000:
        print(a1, a2)
        n = random.randrange(5)
        if n == 0:
            music.play(music.ODE, wait = 0)
        elif n == 1:
            music.play(music.BIRTHDAY, wait = 0)
        elif n == 2:
            music.play(music.RINGTONE, wait = 0)
        elif n == 3:
            music.play(music.DADADADUM, wait = 0)
        else:
            music.play(music.ENTERTAINER, wait = 0)
        display.show(str(n))
        sleep(2000)